package fr.hoteia.appengine.archetype.server.web.controllers;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * <a href="HomeController.java.html"><i>View Source</i></a>
 * </p>
 *
 * @author Denis GOSSET <a href="http://www.hoteia.com"><i>Hoteia.com</i></a>
 * 
 */
@Controller
@RequestMapping("/portal/home*")
public class HomeController extends AbstractHoteiaController {

	protected final Log logger = LogFactory.getLog(getClass());
	
	@RequestMapping(method = RequestMethod.GET)
	public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
		if(logger.isDebugEnabled()){
			logger.debug("home");
		}
		
		ModelAndView modelAndView = new ModelAndView();
		try {
			
			modelAndView = getModelAndView(request, "home", null);
			
			getRequestUtil().handleRequestLanguage(request, response);
			
			Map<String, Object> model = getDefaultModel(request);
			modelAndView.addAllObjects(model);
			
		} catch (Exception e) {
			logger.error("Error on the home controller", e);
		}

		return super.handleRequestInternal(request, response, modelAndView);
	}
	
}
